package com.miya.demo.service.operationlog;

import cn.hutool.json.JSONUtil;
import cn.monitor4all.logRecord.bean.LogDTO;
import cn.monitor4all.logRecord.service.IOperationLogGetService;
import com.miya.demo.entity.LogRecord;
import com.miya.demo.service.LogRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 自定义函数操作日志服务:
 * 本地直接处理消息, 持久化入库
 *
 * @author CaiXiaowei
 * @date 2022/10/13
 */
@Slf4j
@Service
public class CustomFuncOperationLogService implements IOperationLogGetService {

    @Autowired
    private LogRecordService logRecordService;

    @Override
    public void createLog(LogDTO logDTO) {
        log.info("操作日志:{}", JSONUtil.toJsonStr(logDTO));
        LogRecord logRecord = new LogRecord(logDTO);
        logRecordService.save(logRecord);
    }
}
